package com.example.tiptravel.model.impl;

import com.example.tiptravel.api.RetroManager;
import com.example.tiptravel.entity.home.Banner;
import com.example.tiptravel.entity.home.Labels;
import com.example.tiptravel.entity.home.NearBy;
import com.example.tiptravel.entity.home.spot.SpotEntity;
import com.example.tiptravel.model.IHomeModel;

import java.util.Map;

import rx.Scheduler;
import rx.Subscriber;
import rx.android.schedulers.AndroidSchedulers;
import rx.schedulers.Schedulers;

/**
 * Created by 45820 on 2016/11/9.
 */

public class HomeModelImpl implements IHomeModel {

    @Override
    public void getBannerData(Map<String, String> map, Subscriber<Banner> subscriber) {

        RetroManager.getInstance().getHomeService().getBannerData(map)
                .observeOn(AndroidSchedulers.mainThread())
                .subscribeOn(Schedulers.io())
                .subscribe(subscriber);

    }

    @Override
    public void getNearByData(Map<String, String> map, Subscriber<NearBy> subscriber) {

        RetroManager.getInstance().getHomeService().getNearByData(map)
                .observeOn(AndroidSchedulers.mainThread())
                .subscribeOn(Schedulers.io())
                .subscribe(subscriber);

    }

    @Override
    public void getLabelData(Map<String, String> map, Subscriber<Labels> subscriber) {
        RetroManager.getInstance().getHomeService().getLabelData(map)
                .observeOn(AndroidSchedulers.mainThread())
                .subscribeOn(Schedulers.io())
                .subscribe(subscriber);
    }

    @Override
    public void getSpotData(Map<String, String> map, Subscriber<SpotEntity> subscriber) {
        RetroManager.getInstance().getHomeService().getSpotData(map)
                .observeOn(AndroidSchedulers.mainThread())
                .subscribeOn(Schedulers.io())
                .subscribe(subscriber);
    }

}
